﻿using AutoCreatTables.DAL;
using AutoCreatTables.Factory;
using Common.DBUtility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoCreatTables.Business
{
    public class DGetTablesFromDatabase : DbTransaction
    {
        /// <summary>
        /// 数据操作实例
        /// </summary>
        private DTablesManager tablesManagerDAL = null;

        /// <summary>
        /// 数据库名
        /// </summary>
        private string databasename = string.Empty;

        /// <summary>
        /// 表名后缀
        /// </summary>
        private string tablePostfix = string.Empty;

        /// <summary>
        /// 获取数据表
        /// </summary>
        public DGetTablesFromDatabase(string databasename, string tablePostfix)
        {
            this.databasename = databasename;
            this.tablePostfix = tablePostfix;
            this.Connection = ConnectionFactory.DatabaseRead;
            this.IsBeginTransaction = false;
            this.tablesManagerDAL = new DTablesManager();
        }

        /// <summary>
        /// 表名集合
        /// </summary>
        public List<string> TablesList
        {
            get;
            set;
        }

        /// <summary>
        /// 执行
        /// </summary>
        protected override void ExecuteMethods()
        {
            this.TablesList = this.tablesManagerDAL.GetTablesFromDatabase(null, this.Connection, this.databasename, this.tablePostfix);
        }
    }
}
